<script setup>
  import {ref} from "vue";

  const num=ref('');
  const result=ref('');
  let x=parseInt(Math.random()*100)+1;
  console.log(x)
  const guess=()=>{
    if (num.value>x){
      result.value='太大了';
    }else if (num.value<x){
      result.value='太小了';
    }else {
      result.value='恭喜你猜对了';
    }
  }
</script>

<template>
  <h1>猜数字练习</h1>
  <input type="text" placeholder="请输入1~100之间的整数" v-model="num">
  <button @click="guess">猜一猜</button>
  <h3>{{result}}</h3>
</template>

<style scoped>

</style>